package com.weibo4j.api.response.status;

import java.util.List;

import com.weibo4j.api.WeiboResponse;
import com.weibo4j.api.domain.Status;
import com.weibo4j.api.json.JSON;

public abstract class StatusTimelineResponse extends WeiboResponse<List<Status>>{
    
    protected List<Status> model;

    public int getPreviousCursor() {
        return result.getIntValue("previous_cursor");
    }

    public int getNextCursor() {
        return result.getIntValue("next_cursor");
    }

    public int getTotalNumber() {
        return result.getIntValue("total_number");
    }

    @Override
    public List<Status> getModel() {
        if (success && model == null) {
            isSuccess();
        }
        return model;
    }

    @Override
    public boolean isSuccess() {
        boolean isSuccess = super.isSuccess();
        if (isSuccess && model == null) {
            model = JSON.parseArray(result.getString("statuses"), Status.class);
        }
        return isSuccess;
    }
}
